package com.etc.service.impl;

import com.etc.dao.CartDao;
import com.etc.entity.Cart;
import com.etc.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 文件名：com.etc.service.impl
 * 描述：
 * 作者：高文乾
 * 时间： 2019/5/28 14:47.
 */
@Service
public class CartServiceImpl implements CartService {

    @Autowired
    private CartDao cartDao;

    @Override
    public Integer getCartidByUserid(Integer userid) {
        return cartDao.selectCartidByUserid(userid);
    }

    @Override
    public boolean insertCart(Cart cart) {
        return cartDao.insert(cart)>0;
    }

    @Override
    public Cart getCarById ( Integer cartid ) {
        return cartDao.selectByPrimaryKey(cartid);
    }

    @Override
    public Double countOrderSalary ( Integer cartid ) {
        return cartDao.countOrderSalary(cartid);
    }

    /**
     * 根据购物车id删除购物车
     * @param cartid
     * @return
     */
    @Override
    public boolean deleteCartBycartid(Integer cartid) {
        return cartDao.deleteByPrimaryKey(cartid)>0;
    }
}
